package view.menu;

import java.awt.Color;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.util.ArrayList;
import javax.swing.*;
import view.ViewContainer;
import view.ViewHandler;
import view.generaldesign.DesignLayout;

/**
 * 
 * @author Sonny Sandberg
 */
public class MenuLabelLeft extends MenuLabel
{
    public MenuLabelLeft(String text, view.Menu menu)
    {
        super(text, menu);
        
        setOpaque(false);
        setBounds(0, 0, 240, 25);
        setHorizontalAlignment(SwingConstants.LEFT);
        setBorder(BorderFactory.createMatteBorder(0, 0, 1, 0, Color.WHITE));
        setFont(DesignLayout.STANDARD.deriveFont(13f));
        
        MouseAdapter mouseReleased;
        mouseReleased =
                (
                    new MouseAdapter()
                    {
                        public void mouseReleased(MouseEvent evt)
                        {
                            ArrayList<ViewContainer> allViews = view.ViewSingleton.getSingletonObject().getAllViews();
                            for (ViewContainer value : allViews)
                            {
                                value.getTheView().setVisible(false);
                            }
                            ViewHandler.toggleAllsView("designLayout", true);
                            ViewHandler.toggleAllsView("menuTop", true);
                            ViewHandler.toggleAllsView("menuLeft", true);
                            ViewHandler.toggleAllsView("userLoggedInPanel", true);
                            ViewHandler.toggleAllsView(getMenuItem().getNameOfPanel(), true);
                            ViewHandler.setPageTitle(ViewHandler.getPageTitle(getMenuItem().getNameOfPanel()));
                            ViewHandler.toggleAllsView("pageTitle", true);
                                
                            Menu menu = view.ViewSingleton.getSingletonObject().getMenus()[1];
                            menu.resetTextColor(Color.BLACK);
                            
                            setForeground(DesignLayout.MENU_LEFT_TEXT_CHOSEN_BLUE);
                        }
                    }
                );
        
        this.addMouseListener(mouseReleased);
    }
}